<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<meta name="renderer" content="webkit|ie-comp|ie-stand" />
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
<title>学生-课堂-资源</title>
<%@ include file="/common/commonLib.jsp"%>
<link rel="stylesheet" type="text/css" href="<c:url value='/css/lessonResource-stu.css'/>"/>
<link rel="stylesheet" type="text/css" href="<c:url value='/css/common-main.css'/>"/>
<script src="<c:url value='/js/lessonResource-stu.js'/>" type="text/javascript" charset="utf-8"></script>
</head>
<body>
	<div class="container-fluid main">
		<%@include file="/common/header.jsp"%>
		<%@include file="lessonHeader.jsp"%>
		<div class="row">
			<div class="col-md-1"></div>		
			<div class="col-xs-12 col-sm-12 col-md-10">
				<%@include file="lessonNav.jsp"%>
				<!-- 课堂资源列表 -->
				<div class="col-md-12" id="resource-list">
					<div class="row">
						<table class="table table-hover">
							<thead>
								<tr>
									<th class="col1">资源名</th>
									<th class="col2 show-pc">上传者</th>
									<th class="col3">上传时间</th>
									<th class="col3">下载</th>
								</tr>
							</thead>
							<tbody id="resourceList">
								
							</tbody>
						</table>
					</div>												
				</div>				
			</div>			
		</div>		
	</div>
	<%@include file="/common/footer.jsp"%>
</body>
<script>
var data=${data};
$(document).ready(function() {
	if (data.status != "success") {
		alert(data.message);
		return;
	};
	$("#resource").css("color","#00b43c");
	initLesson(data.data.lesson);
	initTable(data.data);
	changeStuLessonUrl(data.data.lesson.classId);
 });

var initTable = function(data){
	 var resourceList =$("#resourceList");
	 resourceList.empty();
	 if(data.list.length <= 0){
		 var s = "<tr><td colspan=\"4\">暂无资源</td></tr>";
		 resourceList.append(s);
	 }else{
		 for(var i=0;i<data.list.length;i++){
			 var item=data.list[i];
			 var s="<tr>";
			 	s+="<td title=\""+item.fileName+"\">"+item.fileName+"</td>";
				s+="<td class=\"show-pc\" title=\""+item.uploaderName+"\">"+item.uploaderName+"</td>";
				s+="<td title=\""+item.uploadTime+"\">"+item.uploadTime+"</td>";
				s+="<td><a href=\"<c:url value='/resource/download/"+item.url+"'/>\">下载</a></td>";
			 s+="</tr>";
			 resourceList.append(s);
		 }
	 }
	 
}
</script>
</html>